<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('合同续租')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tenant-leave" th:object="${sysTenant}">
            <input name="tenantId" th:field="*{tenantId}" type="hidden">  <!--租户id-->
            <input name="tenantStatus" th:field="*{tenantStatus}" type="hidden">  <!--租户状态-->

            <input name="buildingName" th:field="*{buildingName}" type="hidden">
            <input name="buildingId" th:field="*{buildingId}" type="hidden">
            <input name="unitNameStr" th:field="*{unitNameStr}" type="hidden">
            <input name="unitIdStr" th:field="*{unitIdStr}" type="hidden">
            <input name="tenantUse" th:field="*{tenantUse}" type="hidden">
            <input name="tenantName" th:field="*{tenantName}" type="hidden">
            <input name="tenantArea" th:field="*{tenantArea}" type="hidden">
            <input type="hidden" name="rentStartDay" th:value="${#dates.format(sysTenant.rentStartDay, 'yyyy-MM-dd')}" class="input-sm form-control" id="datetimepicker-rentStartDay" placeholder="yyyy-MM-dd"/>
            <input name="risePriceStatus" th:field="*{risePriceStatus}" type="hidden">
            <input name="pledgeFee" th:field="*{pledgeFee}" type="hidden">
            <input name="decorationPledgeFee" th:field="*{decorationPledgeFee}" type="hidden">
            <input name="propertyFee" th:field="*{propertyFee}" type="hidden">
            <input name="utilityFee" th:field="*{utilityFee}" type="hidden">
            <input name="scavengingFee" th:field="*{scavengingFee}" type="hidden">

            <div class="form-group" style="margin-top: 10%">
                <label class="col-sm-3 control-label is-required">合同年限：</label>
                <div class="col-sm-6">
                    <div class="input-daterange input-group">
                        <input type="text" name="startTime" th:value="${#dates.format(sysTenant.endTime, 'yyyy-MM-dd')}" class="input-sm form-control" id="datetimepicker-startTime" placeholder="yyyy-MM-dd" required/>
                        <span class="input-group-addon">到</span>
                        <input type="text" name="endTime" class="input-sm form-control" id="datetimepicker-endTime" placeholder="yyyy-MM-dd" required/>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">每月租金：</label>
                <div class="col-sm-6">
                    <input name="monthlyRentFee" th:field="*{monthlyRentFee}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">涨租时间：</label>
                <div class="col-sm-6">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="risePriceFirstTime" th:value="${#dates.format(sysTenant.risePriceFirstTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">涨租比率：</label>
                <div class="col-sm-6">
                    <input name="risePriceRatio" th:field="*{risePriceRatio}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>

    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>

    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/tenant";
        $("#form-tenant-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $('#form-tenant-leave').serializeArray();
                for(var tmp in data){
                    if(data[tmp].name == "tenantStatus"){
                        data[tmp].value = "0";
                        break;
                    }
                }
                $.operate.save(prefix + "/continue", data);
            }
        }

        $('#unit').selectpicker({
            'width':'300px',
        });

        $("input[name='risePriceFirstTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='rentStartDay']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='startTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

    </script>
</body>
</html>